package com.ojoin.trade.supplyloan_core.web.dao.impl;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.web.dao.impl.BaseDaoImpl;
import com.ojoin.trade.supplyloan_core.web.dao.TbSlSupplysettleaccountCheckDao;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlSupplysettleaccountCheck;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

import org.springframework.stereotype.Repository;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 15-10-22
 * Time: 下午1:20
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class TbSlSupplysettleaccountCheckDaoImpl extends BaseDaoImpl<TbSlSupplysettleaccountCheck> implements TbSlSupplysettleaccountCheckDao {
    @Override
    public void insertTbSlSupplysettleaccountCheck(TbSlSupplysettleaccountCheck vo) throws BusinessException {
        String mapMethodName ="insert";
        try{
            this.sqlSessionTemplate.insert(getSqlName(mapMethodName),vo);
        }catch (Exception e) {
            throw new DaoException(String.format("插入商户账户日监控情况信息表出错！joinid==="+vo.getIdOfTbMerchantUser()+"语句：%s",
                    getSqlName(mapMethodName)), e);
        }



    }
    @Override
    public TbSlSupplysettleaccountCheck queryAccountCheckByJoinidandDate(int joinid, String check_date) throws BusinessException {
       String methodname="selectByJoinidanddate";
        HashMap<String,Object> parammap=new HashMap<String, Object>();
        parammap.put("id_of_tb_merchant_user",joinid);
        parammap.put("check_date",check_date);
        try {
            List list = this.sqlSessionTemplate.selectList(getSqlName(methodname),
                    parammap);
            if (list != null && list.size() >0)
                return (TbSlSupplysettleaccountCheck) list.get(0);
        } catch (Exception e) {
            throw new DaoException(String.format("根据商户的joinid查询商户日结算账户情况信息表出错->" + joinid + "出错！语句：%s",
                    getSqlName(methodname)), e);
        }
        return null;
    }
}
